<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Compares the variable with old value and assigns new value to it</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.wincache-ucache-add.html">wincache_ucache_add</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.wincache-ucache-clear.html">wincache_ucache_clear</a></div>
 <div class="up"><a href="ref.wincache.html">WinCache 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.wincache-ucache-cas" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">wincache_ucache_cas</h1>
  <p class="verinfo">(PECL wincache &gt;= 1.1.0)</p><p class="refpurpose"><span class="refname">wincache_ucache_cas</span> &mdash; <span class="dc-title">
   Compares the variable with old value and assigns new value to it
  </span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.wincache-ucache-cas-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">bool</span> <span class="methodname"><strong>wincache_ucache_cas</strong></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$key</code></span>
   , <span class="methodparam"><span class="type">int</span> <code class="parameter">$old_value</code></span>
   , <span class="methodparam"><span class="type">int</span> <code class="parameter">$new_value</code></span>
   )</div>

  <p class="para rdfs-comment">
   Compares the variable associated with the <em><code class="parameter">key</code></em> with <em><code class="parameter">old_value</code></em> 
   and if it matches then assigns the <em><code class="parameter">new_value</code></em> to it.
  </p>
 </div>

 <div class="refsect1 parameters" id="refsect1-function.wincache-ucache-cas-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<em><code class="parameter">key</code></em></dt>

     <dd>

      <p class="para">
       The <em><code class="parameter">key</code></em> that is used to store the variable in the cache. 
       <em><code class="parameter">key</code></em> is case sensitive.
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">old_value</code></em></dt>

     <dd>

      <p class="para">
       Old value of the variable pointed by <em><code class="parameter">key</code></em> in the user cache. 
       The value should be of type <em>long</em>, otherwise the function returns 
       <strong><code>FALSE</code></strong>.
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">new_value</code></em></dt>

     <dd>

      <p class="para">
       New value which will get assigned to variable pointer by <em><code class="parameter">key</code></em> if a 
       match is found. The value should be of type <em>long</em>, otherwise 
       the function returns <strong><code>FALSE</code></strong>.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>

 <div class="refsect1 returnvalues" id="refsect1-function.wincache-ucache-cas-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   成功时返回 <strong><code>TRUE</code></strong>， 或者在失败时返回 <strong><code>FALSE</code></strong>。
  </p>
 </div>

 <div class="refsect1 examples" id="refsect1-function.wincache-ucache-cas-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-545">
    <p><strong>Example #1 Using <span class="function"><strong>wincache_ucache_cas()</strong></span></strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />wincache_ucache_set</span><span style="color: #007700">(</span><span style="color: #DD0000">'counter'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">2922</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">wincache_ucache_cas</span><span style="color: #007700">(</span><span style="color: #DD0000">'counter'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">2922</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">1</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">wincache_ucache_get</span><span style="color: #007700">(</span><span style="color: #DD0000">'counter'</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>以上例程会输出：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
bool(true) 
int(1)
</pre></div>
    </div>    
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.wincache-ucache-cas-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="function.wincache-ucache-inc.html" class="function" rel="rdfs-seeAlso">wincache_ucache_inc()</a> - Increments the value associated with the key</span></li>
    <li class="member"><span class="function"><a href="function.wincache-ucache-dec.html" class="function" rel="rdfs-seeAlso">wincache_ucache_dec()</a> - Decrements the value associated with the key</span></li>
   </ul>
  </p>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.wincache-ucache-add.html">wincache_ucache_add</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.wincache-ucache-clear.html">wincache_ucache_clear</a></div>
 <div class="up"><a href="ref.wincache.html">WinCache 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
